package com.company.woye.hotmove.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.company.woye.R;
import com.company.woye.hotmove.bean.QuaryQuantity;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class HotMoveQuQanAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context mContext;
    private List<QuaryQuantity> dbhListBeans;

    public HotMoveQuQanAdapter(Context context, List<QuaryQuantity> dbhListBeans) {
        this.inflater = LayoutInflater.from(context);
        this.mContext = context;
        this.dbhListBeans = dbhListBeans;
    }

    @Override
    public int getCount() {
        return dbhListBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return dbhListBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHodler;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_hot_quary_quantity, parent, false);
            viewHodler = new ViewHolder(convertView);
            convertView.setTag(viewHodler);
        } else {
            viewHodler = (ViewHolder) convertView.getTag();
        }
        if (dbhListBeans.size() > 0) {
            QuaryQuantity quaryQuantity = dbhListBeans.get(position);
            viewHodler.tvDBH.setText(quaryQuantity.getDBH());
            viewHodler.tvOrderNo.setText(quaryQuantity.getOrderNo());
            viewHodler.tvPO.setText(quaryQuantity.getPO());
            viewHodler.tvColorNo.setText(quaryQuantity.getColorNo());
            viewHodler.tvSize.setText(quaryQuantity.getSize());
            viewHodler.tvTXM.setText(quaryQuantity.getTXM());
            viewHodler.tvNumber.setText(quaryQuantity.getNumber());
            viewHodler.tvEmpName.setText(quaryQuantity.getEmpName());
            viewHodler.tvScanTime.setText(quaryQuantity.getScanTime());

        }
        return convertView;
    }



    class ViewHolder {
        @BindView(R.id.tv_Size)
        TextView tvSize;
        @BindView(R.id.tv_TXM)
        TextView tvTXM;
        @BindView(R.id.tv_DBH)
        TextView tvDBH;
        @BindView(R.id.tv_OrderNo)
        TextView tvOrderNo;
        @BindView(R.id.tv_PO)
        TextView tvPO;
        @BindView(R.id.tv_ColorNo)
        TextView tvColorNo;
        @BindView(R.id.tv_Number)
        TextView tvNumber;
        @BindView(R.id.tv_EmpName)
        TextView tvEmpName;
        @BindView(R.id.tv_ScanTime)
        TextView tvScanTime;
        @BindView(R.id.ll)
        LinearLayout ll;
        @BindView(R.id.lltop)
        LinearLayout lltop;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
